<template>
  <div>
    <!-- 1.定义面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/guke' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>用户管理</el-breadcrumb-item>
      <el-breadcrumb-item>用户列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 2.定义卡片视图 -->
    <el-card class="box-card">
      <!-- 3.定义栅格的一行 :gutter="20"定义行间距   :span="9" 占位符  -->
      <el-row :gutter="20">
        <el-col :span="9">
          <!-- 3.定义搜索框 -->
          <el-input placeholder="请输入需要查询的用户" v-model="queryInfo.query" clearable @clear="getroomList">
            <el-button slot="append" icon="el-icon-search" @click="getroomList"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 客房数据表格展现  border 边框线属性  -->
      <el-table :data="orderList" border stripe>
        <el-table-column type="index" label="序号"></el-table-column>
        <el-table-column prop="roomId" label="用户ID"></el-table-column>
        <el-table-column prop="roomType" label="姓名"></el-table-column>
        <el-table-column prop="sale" label="性别"></el-table-column>
        <el-table-column prop="people" label="手机号"></el-table-column>

      </el-table>
      <!-- 定义分页组件 关于分页插件的属性说明
            1.@size-change 如果分页中每页实现的条数发生变化 则会触发这个该事件
            2.@current-change 当页数发生改变时,触发该函数
            3.current-page 当前选中的页
            4.page-sizes   页面数据展现的选项
            5.page-size    默认选中的页数
            6.layout    分页中展现的数据种类
            7.total     记录总数
       -->
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="queryInfo.pageNum" :page-sizes="[5, 10, 20]" :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </el-card>
    </el-dialog>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        queryInfo: {
          query: '',
          pageNum: 1,
          pageSize: 5
        },
        //记录总数是数值类型
        total: 0,
        dialogVisible: false,
        addOrdersModel: {
          date: '',
          userName: '',
          sex: '',
          phone: '',
          number: '',
          checkIn: '',
          checkOut: '',
          status: false,
          roomType: '',
          person: ''
        }
      }
    },
    methods: {
      async getroomList() {
        const {
          data: result
        } = await this.$http.get('/room/getRoomList', {
          params: this.queryInfo
        })
        if (result.status !== 200) return this.$message.error("客房列表查询失败")
        this.roomList = result.data.rows
        this.total = result.data.total
        console.log("总记录数:" + this.total)
      },
      //校验员工数据
      addroomBtn() {
        // this.$refs.addroomRef.validate(async valid => {
        //   //如果校验失败 则停止数据
        //   if (!valid) return
        //   let startDate = this.addOrdersModel.date.toString();
        //   this.addOrdersModel.checkIn = startDate.substring(0, 10);
        //   this.addOrdersModel.checkOut = startDate.substring(11)
        //   //console.log(this.addOrdersModel)
        //   const {
        //     data: result
        //   } = await this.$http.post('/orders/addOrders', this.addOrdersModel)
        //   if (result.status !== 200) return this.$message.error("订单新增失败")
        //   this.$message.success("订单新增成功")
        //   //关闭对话框
        //   this.dialogVisible = false
        //   //重新获取员工列表
        //   this.getroomList()
        // })
      },
      handleSizeChange(pageSize) {
        //console.log("每页展现的条数"+pageSize)
        this.queryInfo.pageSize = pageSize
        this.getroomList()
      },
      handleCurrentChange(pageNum) {
        //console.log("页数:"+pageNum)
        this.queryInfo.pageNum = pageNum
        this.getroomList()
      },
      closeDialog() {
        //重置表格数据
        this.$refs.addroomRef.resetFields()
      }
    },
    //利用钩子函数实现数据查询
    mounted() {
      this.getroomList()
    }
  }
</script>


<style lang="less" scoped>

</style>
